﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>添加产品分类</title>
    <link href="~/libs/layui-v2.9.17/layui/css/layui.css" rel="stylesheet" />
    <script src="~/libs/layui-v2.9.17/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>

<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-block">
                <input type="text" name="ItemTypeName" id="ItemTypeName" required lay-verify="required" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序编号</label>
            <div class="layui-input-block">
                <input type="text" name="OrderNum" id="OrderNum" required lay-verify="required" placeholder="请输入排序编号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">产品/物料</label>
            <div class="layui-input-block">
                <input type="radio" name="ItemOrProductId" value="产品" title="产品">
                <input type="radio" name="ItemOrProductId" value="物料" title="物料">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="EnableFlag" value="是" title="是">
                <input type="radio" name="EnableFlag" value="否" title="否">
            </div>
        </div>
        <input type="hidden" name="Id" id="Id">
    </form>
    <script type="text/javascript">
        layui.use('form', function () {
            const form = layui.form;
            form.render();
            var id = window.location.search.substring(4);

            $.ajax({
                url: '/api/ProductClassification/GetMdItemType?id=' + id,
                type: 'get',
                data: $('#form').serialize(),
                success: function (res) {
                    $("#Id").val(res.id)
                    $("#ItemTypeName").val(res.itemTypeName)
                    $("#OrderNum").val(res.orderNum)
                    $("input[name='ItemOrProductId'][value='" + res.itemOrProductId + "']").prop('checked', true);
                    $("input[name='EnableFlag'][value='" + res.enableFlag + "']").prop('checked', true);
                }
            });
        })
    </script>
</body>
</html>